import router from '@system.router';

export default {
    data: {
        pickerData:[
            {
                sexRange:['男','女','保密'],
                selectedSex:'2',
                value:'',
            },
            {
                startDate:'1950-01-01',
                endDate:'2020-12-31',
                selectedDate:'2000-01-01',
                value:'',
            },
            {
                heightRange:[['身高'],[],['cm']],
                selectedHeight:[0,130,0],
                value:'',
            },
            {
                weightRange:[['体重'],[],['kg']],
                selectedWeight:[0,45,0],
                value:'',
            },
        ],
        userData:[
            {
                ID:0,
                title:'性别',
                value:'男',
            },
            {
                ID:1,
                title:'出生年月',
                value:'2000年1月1日',
            },
            {
                ID:2,
                title:'身高',
                value:'160厘米',
            },
            {
                ID:3,
                title:'体重',
                value:'60公斤',
            },
            {
                ID:4,
                title:'兴趣',
                value:'',
            },
        ],
    },
    onInit(){
        for (let i = 30; i <= 230; i++){
            this.pickerData[2].heightRange[1].push(i);
        };
        for (let i = 15; i <= 200; i++) {
            this.pickerData[3].weightRange[1].push(i);
        }
    },

    changeUserdata(e){
        if(e.currentTarget.attr.value === 0){
            this.$element('picker0').show();
        }else if(e.currentTarget.attr.value === 1){
            this.$element('picker1').show();
        }else if(e.currentTarget.attr.value === 2){
            this.$element('picker2').show();
        }else if(e.currentTarget.attr.value === 3){
            this.$element('picker3').show();
        }
    },
    sexChange(e) {
        this.userData[0].value = e.newValue;
    },
    dateChange(e) {
        this.userData[1].value = e.year + '年' + (e.month+1) + '月' + e.day + '日';
    },
    heightChange(e) {
        this.userData[2].value = e.newValue[1] + '厘米';
    },
    weightChange(e) {
        this.userData[3].value = e.newValue[1] + '公斤';
    },
    goBack(){
         router.back();
    }
}
